package com.example.springboot1.service;

import com.example.springboot1.entity.UserMongo;
import com.example.springboot1.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserMongoService {
    @Autowired
    private UserRepository userRepository;

    public String getUserStringByName(String str){
        UserMongo user = userRepository.findByUsername(str);
        if(user != null){
            return user.toString();
        }else{
            return "";
        }
    }

    public UserMongo getUserByName(String str){
        return userRepository.findByUsername(str);
    }

}
